﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HomeWork2_1
{
    class Program
    {
        /* static bool isPrime(int num)//判断是否为素数
        {
            int n = 0;
            if (num == 1)
                return false;
            for(int i = 1; i <= num; i++)
            {
                if (num % i == 0)
                    n++;
            }
            if (n == 2)
                return true;
            else
                return false;
        }*/
        static void Main(string[] args)
        {
            Console.WriteLine("请输入一个正整数");
            try
            {
                int a = Convert.ToInt32(Console.ReadLine());
                if (!(a > 1))
                {
                    Console.WriteLine("1或非正数没有素因子");
                    return;
                }
                Console.WriteLine("该数据的素因子有：");
                for (int i = 2; i <= a; i++)
                {
                    if (a % i == 0)
                        Console.WriteLine(i);
                    while (a % i == 0)
                    {
                        a /= i;
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("请输入正确的数");
            }
        }
    }
}
